package com.bacon.gmall.user.comtroller;

import com.bacon.gmall.common.util.AuthContextHolder;
import com.bacon.gmall.model.user.UserAddress;
import com.bacon.gmall.user.service.UserAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author： bacon、
 * @version： 1.0
 * @create： 2021-01-05 21:05
 * @description:
 */
@RestController
@RequestMapping("/api/user")
public class UserInfoController {

    @Autowired
    private UserAddressService userAddressService;

    //根据userId查找地址
    @GetMapping("/findUserAddressList")
    public List<UserAddress> findUserAddressList(HttpServletRequest request){
        String userId = AuthContextHolder.getUserId(request);

        return userAddressService.findUserAddressList(userId);
    }
}
